﻿#define _CRT_SECURE_NO_WARNINGS

#include"AVLTree.h"
#include<vector>

void TestRotate()
{
	AVLTree<int, int> t;
	// 常规的测试⽤例 
	//int a[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	// 特殊的带有双旋场景的测试⽤例 
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };

	for (auto e : a)
	{
		t.insert({ e,e });
	}
	t.Inorder();
	cout << t.IsBalanceTree() << endl;
}
void TestTreeBalance()
{
	const int N = 1000;
	srand((unsigned int)time(nullptr));
	AVLTree<int, int> t;
	vector<int> v;
	for (int i = 0; i < N; i++)
	{
		v.push_back(rand() + i);
	}
	for (auto e : v)
	{
		t.insert({ e,e });
	}
	cout << t.Height() << endl;;
	cout << t.Size() << endl;
	cout << t.IsBalanceTree() << endl;
}

int main()
{
	//TestRotate();
	TestTreeBalance();
	return 0;
}

